package kuang;

/**
 * @author cyt
 * @create 2020-03-07 11:20
 */

import java.text.SimpleDateFormat;
import java.util.Date;

/***
 * 模拟网络延迟可以方大问题， 便于观察
 */
public class TestSleep implements Runnable {

    private Integer total = 10;

    public static void main(String[] args) {
        new Thread(new TestSleep(), "A").start();
    }

    @Override
    public void run() {
/*        while (total > 0) {
            System.out.println(total--);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }*/

        Date date = new Date(System.currentTimeMillis());
        while (true) {
            try {
                Thread.sleep(1000);
                System.out.println(new SimpleDateFormat("HH-mm-ss").format(date));

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            date = new Date(System.currentTimeMillis());
        }
    }

}
